import React, { Component } from 'react'
import axios from '../http'
// 二次封装

// axios ==> 通过promise对Ajax进行了封装 (ajax)

export default class List extends Component {
    state = {
        list: []
    }
    componentDidMount() {
        axios.get('/getAllList').then(res => {
            this.setState({
                list: res.data.list
            })
            console.log(res)
        })
    }
    render() {
        const { list } = this.state
        return (
            <div>
                <ul>
                    {
                        list.map((item, index) => {
                            return <li key = { index }>
                                <img src = { item.img } alt="" />
                            </li>
                        })
                    }
                </ul>
            </div>
        )
    }
}
